﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Projekt
{
    public partial class newProduce : Form
    {
        UM mert = new UM();
        DataTable UMList;
        public newProduce()
        {
            InitializeComponent();
            UMList = mert.getUMList();
            produceUM.DataSource = UMList;
            produceUM.DisplayMember = "MNev";
        }

        private void produceUM_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void newProduce_Load(object sender, EventArgs e)
        {

        }

        private void Save_Click(object sender, EventArgs e)
        {
            /*
             * idejglenesen itt van az adat ellenorzes
             * */
            bool ok = true;
            if (ProduceName.Text == "") ok = false;
            try
            {
                Int32 tmp = Convert.ToInt32(produceSize.Text);
            }
            catch (Exception) { ok = false; }
            if (ok)
            {
                try
                {
                    DataRow temp = UMList.Rows[produceUM.SelectedIndex];
                    Produce aru = new Produce();
                    aru.add(ProduceName.Text, temp[1].ToString().Trim());
                }
                catch (Exception es) { MessageBox.Show(es.ToString()); }
            }
            else MessageBox.Show("Helytelen adat(ok)");
        }
    }
}
